package com.springDemo.AOP.proxy;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * Created by Administrator on 2016/7/14.
 */
@Aspect
public class PayAspectJ {

    //定义一个任意方法的切面
    @Pointcut(value = "execution(* com.springDemo.AOP..*.payByRMB(..))")
    public void anyMethod(){}

    @Before(value = "anyMethod() && args(name)")
    public void beforeAdvice(String name){
        System.out.println("前置通知: "+name);
    }

    @After(value = "anyMethod()")
    public void afterAdvice(){
        System.out.println("后置通知");
    }

    @Around(value = "execution(* com.springDemo.AOP..*.payByPoint(..))")
    public Object aroundAdvice(ProceedingJoinPoint pd) throws Throwable {
        System.out.println("前置通知");
        Object obj = pd.proceed();
        System.out.println("后置通知");
        return obj;
    }

}
